clear

log using "\\file\UsersW$\wrr15\Home\My Documents\My Files\FIGO'S PAPER\REVISION FOR ECONOMICS E-JOURNAL\Revision (20180407)\FILES FROM FIGO (20180420)\Robust2Results.smcl", replace

etime, start

use "\\file\UsersW$\wrr15\Home\My Documents\My Files\FIGO'S PAPER\REVISION FOR ECONOMICS E-JOURNAL\Revision (20180407)\FILES FROM FIGO (20180420)\FullSample1998-2011.dta"

rename YEAR year

keep if ASSETS>0 
keep if PROFITS>0
keep if EMP>8
drop if DEBT<0  

// We need to delete the fake MNCs by using the following two criteria

keep if FOREIGNCAPITAL > 0
gen ratio = FOREIGNCAPITAL/TOTALCAPITAL
keep if ratio > 0.25

gen d=substr(regst_type,1,1)

count if d=="1"| d=="2"
drop if d=="1" | d=="2" 
// 1 means the state-owned and private enterprise of China. 2 means the enterprises 
// invested by HMT(Hong Kong, Macao, and Taiwan). 3 means the enterprise invested by foreign economies except HMT.

keep if d == "3"

// We use ETR
keep if ETR<100
keep if ETR>0

// If we want, we can redo the analysis by dropping all observations where ETR > 33 percent.
// drop if ETR > 33


// This creates year dummies
tabulate year, gen(year)
// To make the output easier to read, we rename the year dummies
rename year14  y2011
rename year13  y2010
rename year12  y2009
rename year11  y2008
rename year10  y2007
rename year9  y2006
rename year8  y2005
rename year7  y2004
rename year6  y2003
rename year5  y2002
rename year4  y2001
rename year3  y2000
rename year2  y1999
rename year1  y1998

// This sets the sample we will work on in the subsequent analysis
quietly reg lnPROFITS ETR lnSALES lnEMP lnGDP lnKLRAT lnSKILL lnLABOR lnMARK ///
lnPOPDEN lnINFRAS lnFINANCE lnINVFOR y2005-y2009 if year < 2010, vce(cluster FIRM_id)
gen insample = e(sample)

***********************
***********************
******           ******
******  ASSETS   ******
******           ******
***********************
***********************

// This restricts the sample to those cases where we have 
// between 2 and 5 observations per firm ID 
keep if insample == 1
bysort FIRM_id: egen N = count(FIRM_id)
keep if N > 1 & N < 6
tabulate N

// This next section produces the results for TABLE 11

// This calculates the xbar terms
foreach i in ETR lnSALES lnEMP lnGDP lnKLRAT lnSKILL lnLABOR lnMARK lnPOPDEN lnINFRAS lnFINANCE lnINVFOR y2006 y2007 y2008 y2009 {
bysort FIRM_id: egen `i'bar = mean(`i')
}

******** WITHOUT INTERACTION EFFECT ***********

nbreg ASSETS ETR lnSALES lnEMP lnGDP lnKLRAT lnSKILL lnLABOR lnMARK lnPOPDEN ///
  lnINFRAS lnFINANCE lnINVFOR y2006-y2009 ETRbar lnSALESbar lnEMPbar lnGDPbar ///
  lnKLRATbar lnSKILLbar lnLABORbar lnMARKbar lnPOPDENbar lnINFRASbar lnFINANCEbar ///
  lnINVFORbar y2006bar y2007bar y2008bar y2009bar if insample == 1, dispersion(constant) vce(cluster FIRM_id)
est store component1
estat ic
matrix comp1 = r(S)

fmm 2 if insample == 1, vce(cluster FIRM_id)  : nbreg ASSETS ETR lnSALES lnEMP ///
  lnGDP lnKLRAT lnSKILL lnLABOR lnMARK lnPOPDEN lnINFRAS lnFINANCE lnINVFOR ///
  y2006-y2009 ETRbar lnSALESbar lnEMPbar lnGDPbar ///
  lnKLRATbar lnSKILLbar lnLABORbar lnMARKbar lnPOPDENbar lnINFRASbar lnFINANCEbar ///
  lnINVFORbar y2006bar y2007bar y2008bar y2009bar, dispersion(constant)
test _b[ASSETS:2.Class#c.ETR] - _b[ASSETS:1.Class#c.ETR]==0
est store component2
estat ic
matrix comp2 = r(S)

// Evidence that the 2 component model is better that 1 component model
matrix list comp1 
matrix list comp2
lrtest component1 component2, force

// Characteristics of each group
predict fmmpos1 if insample == 1 , classposteriorpr class(1) 
predict fmmpos2 if insample == 1, classposteriorpr class(2)   
count if fmmpos1>fmmpos2  
scalar group1 = r(N)
count if fmmpos1<fmmpos2
scalar group2 = r(N) 	
scalar pctgroup1 = group1/(group1+group2)
scalar pctgroup2 = group2/(group1+group2)
display pctgroup1 pctgroup2

// Creating dummy variables to identify both groups
gen group1=(fmmpos1>fmmpos2)
gen group2=(fmmpos1<fmmpos2)

summ PROFITS if group1 == 1
scalar TOTALPROFITS1 = r(N)*r(mean)
summ ASSETS if group1 == 1
scalar TOTALASSETS1 = r(N)*r(mean)

summ PROFITS if group2 == 1
scalar TOTALPROFITS2 = r(N)*r(mean)
summ ASSETS if group2 == 1
scalar TOTALASSETS2 = r(N)*r(mean)

scalar PROFITSHARE1 = 100*TOTALPROFITS1/(TOTALPROFITS1 + TOTALPROFITS2)
scalar ASSETSHARE1 = 100*TOTALASSETS1/(TOTALASSETS1 + TOTALASSETS2)
scalar list PROFITSHARE1 ASSETSHARE1

summ ASSETS PROFITS EMP SALES if group1 == 1

scalar PROFITSHARE2 = 100*TOTALPROFITS2/(TOTALPROFITS1 + TOTALPROFITS2)
scalar ASSETSHARE2 = 100*TOTALASSETS2/(TOTALASSETS1 + TOTALASSETS2)
scalar list PROFITSHARE2 ASSETSHARE2

summ ASSETS PROFITS EMP SALES if group2 == 1

******** WITH INTERACTION EFFECT ***********

gen treatdum = (year>2007)
gen ETRxTD = ETR*treatdum

bysort FIRM_id: egen ETRxTDbar = mean(ETRxTD)

nbreg ASSETS ETR ETRxTD lnSALES lnEMP lnGDP lnKLRAT lnSKILL lnLABOR lnMARK lnPOPDEN ///
  lnINFRAS lnFINANCE lnINVFOR y2006-y2009 ETRbar ETRxTDbar lnSALESbar lnEMPbar lnGDPbar ///
  lnKLRATbar lnSKILLbar lnLABORbar lnMARKbar lnPOPDENbar lnINFRASbar lnFINANCEbar ///
  lnINVFORbar y2006bar y2007bar y2008bar y2009bar if insample == 1, dispersion(constant) vce(cluster FIRM_id)
est store component1
estat ic
matrix comp1 = r(S)

fmm 2 if insample == 1, vce(cluster FIRM_id)  : nbreg ASSETS ETR ETRxTD  lnSALES lnEMP ///
  lnGDP lnKLRAT lnSKILL lnLABOR lnMARK lnPOPDEN lnINFRAS lnFINANCE lnINVFOR ///
  y2006-y2009 ETRbar ETRxTDbar lnSALESbar lnEMPbar lnGDPbar ///
  lnKLRATbar lnSKILLbar lnLABORbar lnMARKbar lnPOPDENbar lnINFRASbar lnFINANCEbar ///
  lnINVFORbar y2006bar y2007bar y2008bar y2009bar, dispersion(constant)
test _b[ASSETS:2.Class#c.ETRxTD] - _b[ASSETS:1.Class#c.ETRxTD]==0
est store component2
estat ic
matrix comp2 = r(S)

// Evidence that the 2 component model is better that 1 component model
matrix list comp1 
matrix list comp2
lrtest component1 component2, force

etime

log close
